﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;

namespace treadmillProject.src.model {
    [Serializable()]
    public class Speed : ISerializable {
        public Speed(int speedData) {
            Console.WriteLine("Speed init...");
            SpeedData = speedData;
            if (speedData > MaxSpeed) {
                MaxSpeed = speedData;
            }
        }

        public Speed(SerializationInfo info, StreamingContext ctxt) {
            SpeedData = (int) info.GetValue("Speed", typeof (int));
        }

        public int SpeedData { get; set; }
        public static int MaxSpeed { get; set; }

        public void GetObjectData(SerializationInfo info, StreamingContext ctxt) {
            info.AddValue("Speed", SpeedData);
        }
    }
}